package sale.wxb.loveshopping.service;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import sale.wxb.loveshopping.entity.model.SysUser;
import sale.wxb.loveshopping.entity.vo.RegisterVo;
import sale.wxb.loveshopping.entity.vo.common.PageListParam;
import sale.wxb.loveshopping.entity.vo.common.PageRecord;
import sale.wxb.loveshopping.entity.vo.user.AddUserVo;
import sale.wxb.loveshopping.entity.vo.user.SysUserVo;
import sale.wxb.loveshopping.entity.vo.user.UpdateUserVo;

/**
 * <p>
 * 系统用户表 服务类
 * </p>
 *
 * @author 王小宝
 * @since 2022-09-02
 */
public interface ISysUserService extends IService<SysUser> {
    /**
     * 获取用户
     * @param field 字段
     * @param value 值
     * @return SysUser
     */
    SysUser getUser(SFunction<SysUser, ?> field, String value);
    /**
     * 根据token获取用户信息
     * @return SysUser
     */
    SysUser getUserByToken();
    /**
     * 获取用户详情 包含角色、权限
     * @param user 用户对象
     * @return 完整用户信息
     */
    SysUser getUserDetail(SysUser user);
    /**
     * 按账号获取用户
     * @param account 账号
     * @return 系统用户
     */
    SysUser getUserByAccount(String account);
    /**
     * 按邮箱获取用户
     * @param email 邮箱
     * @return 系统用户
     */
    SysUser getUserByEmail(String email);
    /**
     * 按手机号获取用户
     * @param phone 手机号
     * @return 系统用户
     */
    SysUser getUserByPhone(String phone);
    PageRecord<SysUser> getListByPage(PageListParam param);
    Long createAccount(AddUserVo body, String initPassword);
    Long createAccount(AddUserVo body);

    /**
     * 创建账号
     * @param body RegisterVo
     * @return Boolean
     */
    Long createAccount(RegisterVo body);
    /**
     * 更新用户信息
     * @param body UpdateUserVo
     * @return id
     */
    Long updateUserById(UpdateUserVo body);

    /**
     * 按token更新当前用户信息
     * @param body SysUserVo
     * @return Boolean
     */
    Boolean updateUserByToken(SysUserVo body);
}
